Change max internal resolution from centiseconds to microseconds.
authorrobertl <robertl>
Wed, 14 Feb 2007 14:25:36 +0000 (14:25 +0000)
committerrobertl <robertl>
Wed, 14 Feb 2007 14:25:36 +0000 (14:25 +0000)
13 files changed:
defs.h
garmin.c
gdb.c
magproto.c
mapsend.c
mapsource.c
nmea.c
psitrex.c
stmsdf.c
stmwpp.c
tef_xml.c
vitosmt.c
wbt-200.c

diff --git a/defs.h b/defs.h
index ab2024f95b5b9d80f0cc72b997028cd42178ebbf..b7f9bb8362d5fc0da397bfd3b252621d6ce9079b 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -163,6 +163,9 @@ extern const char gpsbabel_version[];
 extern time_t gpsbabel_now;    /* gpsbabel startup-time; initialized in main.c with time() */
 extern time_t gpsbabel_time;   /* gpsbabel startup-time; initialized in main.c with current_time(), ! ZERO within testo ! */
 
+#define CENTI_TO_MICRO(t) (t * 10000) /* Centiseconds to Microseconds */
+#define MICRO_TO_CENTI(t) (t / 10000) /* Centiseconds to Microseconds */
+
 /* Short or Long XML Times */
 #define XML_SHORT_TIME 1
 #define XML_LONG_TIME 2
@@ -326,7 +329,7 @@ typedef struct {
        wp_flags wpt_flags;
        const char *icon_descr;
        time_t creation_time;   /* standardized in UTC/GMT */
-       int centiseconds;       /* Optional hundredths of a second. */
+       int microseconds;       /* Optional millionths of a second. */
        
        /*
         * route priority is for use by the simplify filter.  If we have
index 96b1ac15a460e3bc64742859b67fc880dd5d8e3a..f43b5a18fab6a37b5da72d5ed50397692151cced 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -446,7 +446,7 @@ pvt2wpt(GPS_PPvt_Data pvt, waypoint *wpt)
                - pvt->leap_scnds;
        wptimes = floor(wptime);
        wpt->creation_time = wptimes;
-       wpt->centiseconds = 100.0 * (wptime - wptimes);
+       wpt->microseconds = 1000000.0 * (wptime - wptimes);
        
        /*
         * The Garmin spec fifteen different models that use a different 
diff --git a/gdb.c b/gdb.c
index a389f07cc172b2ab5a8f49fd915c78c8a15eba90..2231f66657f32f88ba74b1e27ad50b395bdd9e92 100644 (file)
--- a/gdb.c
+++ b/gdb.c
@@ -90,8 +90,8 @@
 
 /* %%% local vars %%% */
 
-/* static char gdb_release[] = "$Revision: 1.46 $"; */
-static char gdb_release_date[] = "$Date: 2007/02/06 23:24:14 $";
+/* static char gdb_release[] = "$Revision: 1.47 $"; */
+static char gdb_release_date[] = "$Date: 2007/02/14 14:25:36 $";
 
 static FILE *fin, *fout;
 static char *fin_name, *fout_name;
@@ -890,7 +890,7 @@ gdb_read_track(const size_t max_file_pos)
            wpt->latitude = GPS_Math_Semi_To_Deg(xlat);
            wpt->longitude = GPS_Math_Semi_To_Deg(xlon);
            wpt->creation_time = xtime;
-           wpt->centiseconds = 0;
+           wpt->microseconds = 0;
            wpt->altitude = xalt;
            wpt->depth = xdepth;
            
index 5b45796ee4164b5e446d223d7968f8228ad19104..44c704888df28e334668a8b3125a33de29460ffb 100644 (file)
@@ -923,7 +923,7 @@ mag_trkparse(char *trkmsg)
        tm.tm_mday = dmy % 100; 
 
        waypt->creation_time = mkgmtime(&tm);
-       waypt->centiseconds = fracsecs;
+       waypt->microseconds = CENTI_TO_MICRO(fracsecs);
 
        if (latdir == 'S') latdeg = -latdeg;
        waypt->latitude = ddmm2degrees(latdeg);
@@ -1319,7 +1319,7 @@ void mag_track_disp(const waypoint *waypointp)
                                   tm->tm_sec;
                        date = tm->tm_mday * 10000 + tm->tm_mon * 100 + 
                                   tm->tm_year;
-                       fracsec = waypointp->centiseconds;
+                       fracsec = MICRO_TO_CENTI(waypointp->microseconds);
                }
        }
         if (!tm) {
index b0133a7cc9aa0e7e2684ff6139e34e443ff171bd..c04c9ab50a2a26fee08b42763e30fb340041905e 100644 (file)
--- a/mapsend.c
+++ b/mapsend.c
@@ -214,7 +214,7 @@ mapsend_track_read(void)
                } else {
                        centisecs = 0;
                }
-               wpt_tmp->centiseconds = centisecs;
+               wpt_tmp->microseconds = CENTI_TO_MICRO(centisecs);
                
                track_add_wpt(track_head, wpt_tmp);
        }
@@ -488,7 +488,7 @@ void mapsend_track_disp(const waypoint * wpt)
 
        /* 0 centiseconds */
        if (trk_version >= 30) {
-               c = wpt->centiseconds;
+               c = MICRO_TO_CENTI(wpt->microseconds);
                gbfwrite(&c, 1, 1, mapsend_file_out);
        }
 }
index 01e486426dd81ccd39774da73cfeb45c3b60a0ce..edc5afd69b469c23d59c4e235410a3733c602e10 100644 (file)
@@ -1582,7 +1582,7 @@ mps_track_r(FILE *mps_file, int mps_ver, route_head **trk)
                thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
                thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
                thisWaypoint->creation_time = le_read32(&dateTime);
-               thisWaypoint->centiseconds = 0;
+               thisWaypoint->microseconds = 0;
                thisWaypoint->altitude = mps_altitude;
                thisWaypoint->depth = mps_depth;
                track_add_wpt(track_head, thisWaypoint);
diff --git a/nmea.c b/nmea.c
index 4f757e34cb09b868a7f6fd38d2c43902cae6c061..357b2760bb1b0f1d125748e1fbc689df5418e4aa 100644 (file)
--- a/nmea.c
+++ b/nmea.c
@@ -292,18 +292,18 @@ nmea_set_waypoint_time(waypoint *wpt, struct tm *time)
        if (time->tm_year == 0)
        {
                wpt->creation_time = ((((time_t)time->tm_hour * 60) + time->tm_min) * 60) + time->tm_sec;
-               if (wpt->centiseconds == 0)
+               if (wpt->microseconds == 0)
                {
-                        wpt->centiseconds++;
+                        wpt->microseconds++;
                         without_date++;
                }
        }
        else
        {
                wpt->creation_time = mkgmtime(time);
-               if (wpt->centiseconds != 0)
+               if (wpt->microseconds != 0)
                {
-                       wpt->centiseconds = 0;
+                       wpt->microseconds = 0;
                        without_date--;
                }
        }
@@ -676,11 +676,11 @@ nmea_fix_timestamps(route_head *track)
                {
                        waypoint *wpt = (waypoint *)elem;
                        
-                       if (wpt->centiseconds != 0)
+                       if (wpt->microseconds != 0)
                        {
                                time_t dt;
                                
-                               wpt->centiseconds = 0;          /* reset flag */
+                               wpt->microseconds = 0;          /* reset flag */
 
                                dt = (prev / SECONDS_PER_DAY) * SECONDS_PER_DAY;
                                wpt->creation_time += dt;
index e2aa4fb1700a8067b86912fee402628ddb8372b0..739fec4c9c9feaa9b43b07ffe7d0ebbebbed832e 100755 (executable)
--- a/psitrex.c
+++ b/psitrex.c
@@ -597,7 +597,6 @@ psit_track_r(gbfile *psit_file, route_head **trk)
                        }
 
                        thisWaypoint->creation_time = dateTime;
-                       thisWaypoint->centiseconds = 0;
                        track_add_wpt(track_head, thisWaypoint);
 
                        if (gbfeof(psit_file)) break;
index bc2e861e5cbc06ee113aee97b058ce8edb470093..af4a68062babd6c565924b4b17ba15df91258369 100644 (file)
--- a/stmsdf.c
+++ b/stmsdf.c
@@ -192,7 +192,7 @@ finalize_tracks(void)
 
        for (index = 0; index < count; index++) {
                waypoint *wpt = list[index];
-               if (wpt->centiseconds == 2) {   /* log continued */
+               if (wpt->microseconds == 2) {   /* log continued */
                        track = NULL;
                }
                if (track == NULL) {
@@ -209,10 +209,10 @@ finalize_tracks(void)
                                track->rte_desc = xstrdup(rte_desc);
                }
                track_add_wpt(track, wpt);
-               if (wpt->centiseconds == 1) { /* log pause */
+               if (wpt->microseconds == 1) { /* log pause */
                        track = NULL;
                }
-               wpt->centiseconds = 0;
+               wpt->microseconds = 0;
        }
 
        xfree(list);
@@ -290,7 +290,7 @@ parse_point(char *line)
                        case 10:
                                break;
                        case 11:
-                               if (what == 1) wpt->centiseconds = atoi(str); /* memory point type */
+                               if (what == 1) wpt->microseconds = atoi(str); /* memory point type */
                                break;
                }
        }
index 288b21117208435e956e970f2063ce0c334bf6eb..f82f5e43c163638b21d84b8b103a8eee3c1f1606 100644 (file)
--- a/stmwpp.c
+++ b/stmwpp.c
@@ -92,6 +92,7 @@ stmwpp_data_read(void)
                while (c != NULL)
                {
                        int new_what;
+                       int fracsec;
                        
                        switch(column)
                        {
@@ -135,9 +136,10 @@ stmwpp_data_read(void)
                                        break;
                                        
                                case 6:
-                                       sscanf(c, "%d:%d:%d.%d", &time.tm_hour, &time.tm_min, &time.tm_sec, &wpt->centiseconds);
+                                       sscanf(c, "%d:%d:%d.%d", &time.tm_hour, &time.tm_min, &time.tm_sec, &fracsec);
+                                       wpt->microseconds = CENTI_TO_MICRO(fracsec);
                                        if (what == STM_TRKPT)
-                                               wpt->centiseconds /= 10;
+                                               wpt->microseconds /= 10;
                                        break;
                                        
                                default:
@@ -247,10 +249,10 @@ stmwpp_waypt_cb(const waypoint *wpt)
        {
                case STM_WAYPT:
                case STM_RTEPT:
-                       gbfprintf(fout, ".%02d", wpt->centiseconds);
+                       gbfprintf(fout, ".%02d", MICRO_TO_CENTI(wpt->microseconds));
                        break;
                case STM_TRKPT:
-                       gbfprintf(fout, ".%03d", wpt->centiseconds * 10);
+                       gbfprintf(fout, ".%03d", MICRO_TO_CENTI(wpt->microseconds * 10));
                        break;
        }
        gbfprintf(fout, ",\r\n");
index 3112d5fc5dd86a0830d55cc2e61483b665dee9b6..9308f20363966a960e8e61107701324b683e717d 100644 (file)
--- a/tef_xml.c
+++ b/tef_xml.c
@@ -151,8 +151,8 @@ void waypoint_final()
        int via;
        if (wpt_tmp == NULL) return;
 
-       via = wpt_tmp->centiseconds;
-       wpt_tmp->centiseconds = 0;
+       via = wpt_tmp->microseconds;
+       wpt_tmp->microseconds = 0;
        
        if (via != 0)
            waypt_add(wpt_tmp);
@@ -202,10 +202,9 @@ tef_item_start(const char *args, const char **attrv)
        const char **avp = &attrv[0];
 
        wpt_tmp = waypt_new();
-       wpt_tmp->centiseconds = 0;
        
        if ((waypoints == 1) || (waypoints == item_count)) 
-           wpt_tmp->centiseconds++;
+           wpt_tmp->microseconds++;
            
        waypoints++;
        
@@ -221,7 +220,7 @@ tef_item_start(const char *args, const char **attrv)
            }
            if ((0 == strcmp(avp[0], "ViaStation")) && (0 == strcmp(avp[1], "true")))
            {
-               wpt_tmp->centiseconds = 1;
+               wpt_tmp->microseconds = 1;
            }
            avp+=2;
        }
index 4a9bedf64efe0aaae6fe7c743bbf1f519e11694b..44404a05b11f9e73c27ddc7219a211bd64448c75 100644 (file)
--- a/vitosmt.c
+++ b/vitosmt.c
@@ -183,7 +183,7 @@ vitosmt_read(void)
                tmStruct.tm_isdst       =-1;
 
                wpt_tmp->creation_time = mkgmtime(&tmStruct);
-               wpt_tmp->centiseconds = fmod(100*seconds+0.5,100);
+               wpt_tmp->microseconds = fmod(1000000*seconds+0.5,1000000);
        
                wpt_tmp->shortname      =xcalloc(16,1);
                snprintf(wpt_tmp->shortname, 15 , "WP%04d", ++serial);
@@ -274,7 +274,7 @@ vitosmt_waypt_pr(const waypoint *waypointp)
        position += sizeof(double);
 
        tmstructp =  gmtime(&waypointp->creation_time);
-       seconds = (double) tmstructp->tm_sec + 0.01*waypointp->centiseconds;
+       seconds = (double) tmstructp->tm_sec + 0.0000001*waypointp->microseconds;
 
        workbuffer[position++]  =tmstructp->tm_year-100;
        workbuffer[position++]  =tmstructp->tm_mon+1;
index e497c619cabfedc5158dd3f231a0fd57aa2e34cb..66344fa745875d75957af1b37ebd08c1ebf5abbb 100644 (file)
--- a/wbt-200.c
+++ b/wbt-200.c
@@ -392,7 +392,6 @@ static int data_chunk(struct read_state *st, const void *buf, int fmt) {
                wpt->longitude      = lon;
                wpt->altitude       = alt;
                wpt->creation_time  = rtim;
-               wpt->centiseconds   = 0;
 
                sprintf(wp_name, "WP%04d", ++st->wpn);
                wpt->shortname      = xstrdup(wp_name);